import { getUrlParameter, useLocalStorage } from '@/units'
// import { initAllModulesList } from '@/router/BuriedPoint.js'
const portNumMap = new Map([
  [0, 'park'], //政府端
  [1, 'enterprise'], //企业端
])
const portNameMap = new Map([
  ['park', 0],
  ['enterprise', 1],
])

/**
 * 重置运行端
 */
const initPort = () => {
  if (import.meta.env.MODE === 'development') {
    if (getUrlParameter('type') === 'enterprise') {
      localStorage.setItem('loginMode', 'enterprise')
    } else if (!localStorage.getItem('loginMode')) {
      localStorage.setItem('loginMode', 'park')
    }
  } else {
    if (window.location.pathname.includes('enterprise/')) {
      localStorage.setItem('loginMode', 'enterprise')
    } else {
      localStorage.setItem('loginMode', 'park')
    }
  }
  // initAllModulesList()
}

/**
 * 判断运行端
 * return {Number} 0 1
 */
const judgePort = () => {
  return portNameMap.get(localStorage.getItem('loginMode'))
}
const judgePortName = () => {
  return localStorage.getItem('loginMode')
}

export { initPort, judgePort, judgePortName }
